summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Lombardo <clombardo169@gmail.com>2023-03-11 06:34:24 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:39 +0200
commit0f742b3464d596fdb55162c2d0cd5aff14405b34 (patch)
tree17f92433ad094a5a5948503547431818955b7868
parentandroid: Convert InputOverlayDrawableJoystick to Kotlin (diff)
downloadyuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar.gz
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar.bz2
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar.lz
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar.xz
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.tar.zst
yuzu-0f742b3464d596fdb55162c2d0cd5aff14405b34.zip
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.java81
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.kt66
2 files changed, 66 insertions, 81 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.java
deleted file mode 100644
index d2ef753bc..000000000
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package org.yuzu.yuzu_emu.ui.main;
-
-import android.os.SystemClock;
-
-import org.yuzu.yuzu_emu.BuildConfig;
-import org.yuzu.yuzu_emu.YuzuApplication;
-import org.yuzu.yuzu_emu.R;
-import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile;
-import org.yuzu.yuzu_emu.model.GameDatabase;
-import org.yuzu.yuzu_emu.utils.AddDirectoryHelper;
-
-public final class MainPresenter {
- public static final int REQUEST_ADD_DIRECTORY = 1;
- public static final int REQUEST_INSTALL_KEYS = 2;
- public static final int REQUEST_SELECT_GPU_DRIVER = 3;
- private final MainView mView;
- private String mDirToAdd;
- private long mLastClickTime = 0;
-
- public MainPresenter(MainView view) {
- mView = view;
- }
-
- public void onCreate() {
- String versionName = BuildConfig.VERSION_NAME;
- mView.setVersionString(versionName);
- refreshGameList();
- }
-
- public void launchFileListActivity(int request) {
- if (mView != null) {
- mView.launchFileListActivity(request);
- }
- }
-
- public boolean handleOptionSelection(int itemId) {
- // Double-click prevention, using threshold of 500 ms
- if (SystemClock.elapsedRealtime() - mLastClickTime < 500) {
- return false;
- }
- mLastClickTime = SystemClock.elapsedRealtime();
-
- switch (itemId) {
- case R.id.menu_settings_core:
- mView.launchSettingsActivity(SettingsFile.FILE_NAME_CONFIG);
- return true;
-
- case R.id.button_add_directory:
- launchFileListActivity(REQUEST_ADD_DIRECTORY);
- return true;
-
- case R.id.button_install_keys:
- launchFileListActivity(REQUEST_INSTALL_KEYS);
- return true;
-
- case R.id.button_select_gpu_driver:
- launchFileListActivity(REQUEST_SELECT_GPU_DRIVER);
- return true;
- }
-
- return false;
- }
-
- public void addDirIfNeeded(AddDirectoryHelper helper) {
- if (mDirToAdd != null) {
- helper.addDirectory(mDirToAdd, mView::refresh);
-
- mDirToAdd = null;
- }
- }
-
- public void onDirectorySelected(String dir) {
- mDirToAdd = dir;
- }
-
- public void refreshGameList() {
- GameDatabase databaseHelper = YuzuApplication.databaseHelper;
- databaseHelper.scanLibrary(databaseHelper.getWritableDatabase());
- mView.refresh();
- }
-}
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.kt
new file mode 100644
index 000000000..b2d731494
--- /dev/null
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/ui/main/MainPresenter.kt
@@ -0,0 +1,66 @@
+package org.yuzu.yuzu_emu.ui.main
+
+import org.yuzu.yuzu_emu.BuildConfig
+import org.yuzu.yuzu_emu.R
+import org.yuzu.yuzu_emu.YuzuApplication
+import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
+import org.yuzu.yuzu_emu.utils.AddDirectoryHelper
+
+class MainPresenter(private val view: MainView) {
+ private var dirToAdd: String? = null
+
+ fun onCreate() {
+ val versionName = BuildConfig.VERSION_NAME
+ view.setVersionString(versionName)
+ refreshGameList()
+ }
+
+ private fun launchFileListActivity(request: Int) {
+ view.launchFileListActivity(request)
+ }
+
+ fun handleOptionSelection(itemId: Int): Boolean {
+ when (itemId) {
+ R.id.menu_settings_core -> {
+ view.launchSettingsActivity(SettingsFile.FILE_NAME_CONFIG)
+ return true
+ }
+ R.id.button_add_directory -> {
+ launchFileListActivity(REQUEST_ADD_DIRECTORY)
+ return true
+ }
+ R.id.button_install_keys -> {
+ launchFileListActivity(REQUEST_INSTALL_KEYS)
+ return true
+ }
+ R.id.button_select_gpu_driver -> {
+ launchFileListActivity(REQUEST_SELECT_GPU_DRIVER)
+ return true
+ }
+ }
+ return false
+ }
+
+ fun addDirIfNeeded(helper: AddDirectoryHelper) {
+ if (dirToAdd != null) {
+ helper.addDirectory(dirToAdd) { view.refresh() }
+ dirToAdd = null
+ }
+ }
+
+ fun onDirectorySelected(dir: String?) {
+ dirToAdd = dir
+ }
+
+ private fun refreshGameList() {
+ val databaseHelper = YuzuApplication.databaseHelper
+ databaseHelper!!.scanLibrary(databaseHelper.writableDatabase)
+ view.refresh()
+ }
+
+ companion object {
+ const val REQUEST_ADD_DIRECTORY = 1
+ const val REQUEST_INSTALL_KEYS = 2
+ const val REQUEST_SELECT_GPU_DRIVER = 3
+ }
+}